import request from '@/utils/request';

//获取小区列表
export async function GetTreeSelect(params) {
    try {
        const res = await request.get('/api/system/dept/treeselectPlace', {
            params
        });
        return res && res.code == 200 ? Promise.resolve(res) : Promise.reject(res.msg)
    } catch (error) {
        return Promise.reject(error)
    }
}

export async function GetPlaces(params) {
    try {
        const res = await request.post('/places', {
            params
        });
        return res && res.code == 200 ? Promise.resolve(res) : Promise.reject(res.msg)
    } catch (error) {
        return Promise.reject(error)
    }
}

export async function GetAlarmsList(params) {
    try {
        const res = await request.get('/api/mapDateInfo/getDeviceAlarmInfo', {
            params
        });
        return res && res.code == 200 ? Promise.resolve(res) : Promise.reject(res.msg)
    } catch (error) {
        return Promise.reject(error)
    }
    // /dataAnalysis/historydata/list
}

export async function GetReportList(params) {
    try {
        const res = await request.get('/api/mapDateInfo/getDeviceInfo', {
            params
        });
        return res && res.code == 200 ? Promise.resolve(res) : Promise.reject(res.msg)
    } catch (error) {
        return Promise.reject(error)
    }
}

//获取报警最新20条数据
export async function getAlarmInfo(params) {
  try {
    const res = await request.get('/api/alarmInfo/getAlarmInfo', {
      params
    });
    return res && res.code == 200 ? Promise.resolve(res) : Promise.reject(res.msg)
  } catch (error) {
    return Promise.reject(error)
  }
}

//获取智慧门禁前20条信息
export async function getDoorAccessInfo(params) {
  try {
    const res = await request.get('/api/mapGate/getDoorAccessInfo', {
      params
    });
    return res && res.code == 200 ? Promise.resolve(res) : Promise.reject(res.msg)
  } catch (error) {
    return Promise.reject(error)
  }
}
//分页获取门禁人证机登记信息
export async function getDoorAccessInfoForPage(params) {
  try {
    const res = await request.get('/api/mapGate/getDoorAccessInfoForPage', {
      params
    });
    return res && res.code == 200 ? Promise.resolve(res) : Promise.reject(res.msg)
  } catch (error) {
    return Promise.reject(error)
  }
}

//电子围栏20条
export async function GetImsiInfo(params) {
  try {
      const res = await request.get('/api/imsiInfo/getImsiInfo', {
          params
      });
      return res && res.code == 200 ? Promise.resolve(res) : Promise.reject(res.msg)
  } catch (error) {
      return Promise.reject(error)
  }
}

//电子围栏历史
export async function GetImsiInfoForPage(params) {
  try {
      const res = await request.get('/api/imsiInfo/getImsiInfoForPage', {
          params
      });
      return res && res.code == 200 ? Promise.resolve(res) : Promise.reject(res.msg)
  } catch (error) {
      return Promise.reject(error)
  }
}
